<?php
/*********************************************************************************
* Filename: no_schedule.php
* 
* This page is used to present the user with the final league standings.  This
* page can only be accessed when the league games are completely done.
*
*
* Author: Phillip Peterson
* Date Created: 09/26/2009
**********************************************************************************/
 
//Start the PHP session is it doesn't exist
if (!isset($_SESSION))
	session_start();
//Check if the team is logged in.  If not, redirect the user
//to the login page.
if (!isset($_SESSION['team_id'])){
	include_once "common.php";
	$path = $g_server . $g_login_page;

	header("Location: $path");
	die();
}
   
//The common.php file contains 
include_once "common.php";

//Store the team id which is stored in the session log
$team_id = $_SESSION['team_id'];

echo "$header_open";
echo "$css_league_home";
echo "$js_league_home";
echo "$header_close";

?>

<?php 
    $query = "SELECT * FROM TEAMS WHERE TEAM_ID = $team_id";
    $results = do_query($query, $g_db_name, $g_username);
    $row = mysql_fetch_assoc($results);
    $the_league = $row['LEAGUE_ID'];
    
    $query = "SELECT *, UNIX_TIMESTAMP(DRAFT_DATE) AS DATE FROM LEAGUES WHERE LEAGUE_ID = $the_league";
    $results = do_query($query, $g_db_name, $g_username);
    $row = mysql_fetch_assoc($results);
    $draft_done = $row['DRAFT_DONE'];
    $draft_date = date("F j, Y",$row['DATE']);
    $draft_type = ($row['DRAFT']) ? 'Live Draft' : 'Random Draft';
    $scheduled = $row['SCHEDULED'];
    
    if ($draft_done && !$scheduled) {
        echo "<body>";
        echo "<div id='wrapper'>";
            echo "<div id='inner'>";
                echo "$g_nav_div";
                echo "<div id='content'>";
                    echo "<img onclick='scheduleLeague();' 
                               onmousehover='hoverButton(this);'
                               id='no_draft' src='images/scheduleButton.jpg' width='390' height='152'>";
                echo "</div>";
                echo "<div id='footer'>";
                    echo "$footer;";
			    echo "</div>";
            echo "</div>";
        echo "</div>";
        echo "</body>";
        echo "</html>";
    }
      
    else {
    	$path = $g_server . $g_login_page;
    	header("Location: $path");
    	die();
    }
?>
